<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>SAMSUNG三星商城后台</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <link rel="shortcut icon" href="../x-admin/favicon.ico" type="image/x-icon" />
    <link rel="stylesheet" href="../x-admin/css/font.css">
    <link rel="stylesheet" href="../x-admin/css/xadmin.css">


    <link rel="stylesheet" href="https://cdn.bootcss.com/Swiper/3.4.2/css/swiper.min.css">
    <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
    <script type="text/javascript" src="https://cdn.bootcss.com/Swiper/3.4.2/js/swiper.jquery.min.js"></script>
    <script src="../x-admin/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="../x-admin/js/xadmin.js"></script>



</head>
<body>
<!-- 顶部开始 -->

<!-- 顶部结束 -->
<!-- 中部开始 -->
<div class="wrapper">

    <!-- 左侧菜单结束 -->
    <!-- 右侧主体开始 -->
    <%--商品id--%>
    <%--商品名称--%>
    <form id="forminput">
        <div class="layui-form-item">
            <label for="level-name" class="layui-form-label">
                商品名称
            </label>
            <div class="layui-input-inline">
                <input type="text" id="level-name" name="level-id" disabled="" value="${commodities[0].sname}" class="layui-input">
            </div>
        </div>

        <%--详情颜色--%>
        <div class="layui-form-item">
            <label for="level-color" class="layui-form-label">
                <span class="x-red">详情颜色</span>
            </label>
            <div class="layui-input-inline">
                <%--        <input type="text" id="level-leibie" name="level-kiss" required="" value="0-1000" lay-verify="required"--%>
                <%--               autocomplete="off" class="layui-input">--%>
                <select name="level-color" id="level-color" required="" lay-verify="required" autocomplete="off" class="layui-input">
                    <c:forEach items="${commoditycolors}" var="x">
                        <option value="${x.yid}">${x.yname}</option>
                    </c:forEach>
                </select>
            </div>
        </div>
<%--        详情内存--%>
        <div class="layui-form-item">
            <label for="level-memory" class="layui-form-label">
                <span class="x-red">详情内存</span>
            </label>
            <div class="layui-input-inline">
                <%--        <input type="text" id="level-leibie" name="level-kiss" required="" value="0-1000" lay-verify="required"--%>
                <%--               autocomplete="off" class="layui-input">--%>
                <select name="level-memory" id="level-memory" required="" lay-verify="required" autocomplete="off" class="layui-input">
                    <c:forEach items="${commoditymemories}" var="x">
                        <option value="${x.nid}">${x.nname}</option>
                    </c:forEach>
                </select>
            </div>
        </div>
        <%--详情价格--%>
        <div class="layui-form-item">
            <label for="level-price" class="layui-form-label">
                <span class="x-red">详情价格</span>
            </label>
            <div class="layui-input-inline">
                <input type="text" id="level-price" name="level-price" required="" value="" lay-verify="required"
                       autocomplete="off" class="layui-input" placeholder="价格">
            </div>
        </div>
        <%--商品前端预览图--%>
        <div class="layui-form-item">
            <label class="layui-form-label">
            </label>
            <input type="hidden" class="hiddensid" value="${commodities[0].sid}">
            <button id="addgoods"  class="layui-btn" type="button" onclick="addgoodxq()">
                添加详情
            </button>
        </div>
        <%--        添加商品详情--%>
    </form>

    <!-- 右侧主体结束 -->
</div>

</body>
<script>
    function addgoodxq(){
        var xprice = document.querySelector("#level-price").value;
        console.log("商品详情价格"+xprice);
        var yid = document.querySelector("#level-color").value;
        var nid = document.querySelector("#level-memory").value;
        var sid = document.querySelector(".hiddensid").value;
        if (document.querySelector("#level-price").value == ""){
            layer.msg("请填写商品价格", {icon: 2 ,time: 1000});
            return null;
        }

        $.ajax({
            url:"/goodsxq?v=goodsxqadd",
            type:"post",
            data: {
                xprice,
                yid,
                nid,
                sid
            },
            success:function (resp) {
                if (resp>0){
                    layer.msg("添加成功！",{icon:1,time:1000},function () {
                        // 获得frame索引
                        var index = parent.layer.getFrameIndex(window.name);
                        //关闭当前frame
                        parent.layer.close(index);

                    });

                }else{
                    layer.msg("添加失败！",{icon:2})
                }
            }

        })
    }

    //类别添加
    function member_add(title,url,w,h){
        x_admin_show(title,url,w,h);
    }

</script>
</html>